/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Produtos;

import CRM.BancoDeDadosEstoque;
import CRM.Produto;
import CRM.Util;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author User
 */
public class CadastrodeProduto extends javax.swing.JDialog {

    {
        //determina que a janela ficara centralizada
        setSize(502, 556);

        // centraliza a janela    
        setLocationRelativeTo(null);
    }

    /**
     * Creates new form CadastrodeProduto
     */
    public CadastrodeProduto(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();

        colunas.add("Código");
        colunas.add("Nome");
        colunas.add("Preço");
        colunas.add("Valor Compra");
        colunas.add("total Vendido");

        model = new DefaultTableModel(linhas, colunas);

        tfTabela.setModel(model);
        carregaProdutos();
    }
    Vector colunas = new Vector();
    Vector linhas = new Vector();
    DefaultTableModel model = null;

    private void apagar() {
        int row = tfTabela.getSelectedRow();

        if (row != -1) {
            Object value = tfTabela.getValueAt(row, 0);

            if (value != null) {
                if (JOptionPane.showConfirmDialog(this, "Deseja apagar?") == JOptionPane.OK_OPTION) {
                    int id = Integer.parseInt(value.toString());

                    Produto p = BancoDeDadosEstoque.getInstance().buscaProduto(id);

                    BancoDeDadosEstoque.getInstance().excluiProduto(p);

                    tfNome1.setText("");
                    tfPreco1.setText("");
                    tfQuantidadeDisponivel1.setText("");
                    tfQuantidadeMinima1.setText("");
                    tfValorCompra1.setText("");
                    tfDescricao1.setText("");

                    carregaProdutos();
                }
            }
        }

    }

    private void editar() {
        if (selecionado != null) {
            String nome = tfNome1.getText();
            String preco = tfPreco1.getText();
            String quantidadeDisp = tfQuantidadeDisponivel1.getText();
            String quantidadeMin = tfQuantidadeMinima1.getText();
            String valorDeCompra = tfValorCompra1.getText();
            String descricao = tfDescricao1.getText();

            selecionado.setNome(nome);
            selecionado.setPreco(Util.toDouble(preco));
            selecionado.setQuantidadedisponivel(Util.toInt(quantidadeDisp));
            selecionado.setQuantidademinima(Util.toInt(quantidadeMin));
            selecionado.setValordecompra(Util.toDouble(valorDeCompra));
            selecionado.setDescricao(descricao);

            BancoDeDadosEstoque.getInstance().alterarProduto(selecionado);

            selecionado = null;

            JOptionPane.showMessageDialog(rootPane, " Produto alterado com sucesso!!! ");
            tfNome1.setText("");
            tfPreco1.setText("");
            tfQuantidadeDisponivel1.setText("");
            tfQuantidadeMinima1.setText("");
            tfValorCompra1.setText("");
            tfDescricao1.setText("");


            carregaProdutos();


        } else {
            JOptionPane.showMessageDialog(rootPane, "##Nao foi possível alterar Produto##");
        }
    }

    private void carregaProdutos() {
        Vector<Produto> produtos = BancoDeDadosEstoque.getInstance().buscaProdutos();

        linhas.clear();



        for (Produto p : produtos) {
            Vector dados = new Vector();
            dados.add(p.getCodigo());
            dados.add(p.getNome());
            dados.add(p.getPreco());
            dados.add(p.getValordecompra());
            dados.add(BancoDeDadosEstoque.getInstance().totalVendasPorProduto(p));


            linhas.add(dados);
        }

        model.fireTableDataChanged();
    }

    private void adicionarProdutoNaLista() {
        Produto p = new Produto();
        String nome = tfNome1.getText();
        String preco = tfPreco1.getText();
        String qtdDisponivel = tfQuantidadeDisponivel1.getText();
        String qtdMinima = tfQuantidadeMinima1.getText();
        String valordeCompra = tfValorCompra1.getText();
        String descricao = tfDescricao1.getText();
        if (nome.isEmpty()) {
            JOptionPane.showMessageDialog(rootPane, " ##ERROR informe o nome do produto## ");
        } else if (preco.isEmpty()) {
            JOptionPane.showMessageDialog(rootPane, " ##ERROR informe o preço do produto## ");
        } else if (qtdDisponivel.isEmpty()) {
            JOptionPane.showMessageDialog(rootPane, " ##ERROR informe a quantidade disponível do produto## ");
        } else if (qtdMinima.isEmpty()) {
            JOptionPane.showMessageDialog(rootPane, " ##ERROR informe a quantidade mínima do produto## ");
        } else if (valordeCompra.isEmpty()) {
            JOptionPane.showMessageDialog(rootPane, " ##ERROR informe o valor de compra do produto## ");
        } else if (descricao.isEmpty()) {
            JOptionPane.showMessageDialog(rootPane, " ##ERROR informe uma descrição do produto## ");
        } else {

            p.setNome(tfNome1.getText());
            p.setPreco(Util.toDouble(tfPreco1.getText()));
            p.setQuantidadedisponivel(Util.toInt(tfQuantidadeDisponivel1.getText()));
            p.setQuantidademinima(Util.toInt(tfQuantidadeMinima1.getText()));
            p.setValordecompra(Util.toDouble(tfValorCompra1.getText()));
            p.setDescricao(tfDescricao1.getText());

            BancoDeDadosEstoque bde = BancoDeDadosEstoque.getInstance();
            bde.salvaProduto(p);

            // dispose();
            {
                JOptionPane.showMessageDialog(rootPane, " Produto cadastrado com sucesso!!! ");
            }
            tfNome1.setText("");
            tfPreco1.setText("");
            tfQuantidadeDisponivel1.setText("");
            tfQuantidadeMinima1.setText("");
            tfValorCompra1.setText("");
            tfDescricao1.setText("");

            carregaProdutos();
        }
    }
    private Produto selecionado = null;

    private void selecionaItemNaTabela() {
        int row = tfTabela.getSelectedRow();

        if (row != -1) {
            Object value = tfTabela.getValueAt(row, 0);

            if (value != null) {

                int id = Integer.parseInt(value.toString());

                Produto p = BancoDeDadosEstoque.getInstance().buscaProduto(id);

                tfNome1.setText(String.valueOf(p.getNome()));
                tfPreco1.setText(String.valueOf(p.getPreco()));
                tfQuantidadeDisponivel1.setText(String.valueOf(p.getQuantidadedisponivel()));
                tfQuantidadeMinima1.setText(String.valueOf(p.getQuantidademinima()));
                tfValorCompra1.setText(String.valueOf(p.getValordecompra()));
                tfDescricao1.setText(String.valueOf(p.getDescricao()));

                selecionado = p;

            }
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jScrollPane5 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        tfNome1 = new javax.swing.JTextField();
        tfPreco1 = new javax.swing.JTextField();
        tfQuantidadeDisponivel1 = new javax.swing.JTextField();
        tfQuantidadeMinima1 = new javax.swing.JTextField();
        tfValorCompra1 = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tfDescricao1 = new javax.swing.JTextArea();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jScrollPane6 = new javax.swing.JScrollPane();
        tfTabela = new javax.swing.JTable();
        jButton4 = new javax.swing.JButton();

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane4.setViewportView(jTable1);

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane5.setViewportView(jTable2);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Cadastrar Produtos"));

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel1.setText("Cadastro de Produtos");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel3.setText("Nome:");

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel4.setText("Descrição:");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel5.setText("Preço:");

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel6.setText("Quant.Disponivel:");

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel7.setText("Quant.Minima:");

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel16.setText("Valor de Compra:");

        tfDescricao1.setColumns(20);
        tfDescricao1.setRows(5);
        jScrollPane2.setViewportView(tfDescricao1);

        jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton1.setText("Apagar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton2.setText("Alterar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jButton3.setText("Adicionar");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        tfTabela.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Código", "Nome", "Preço", "Valor Compra", "Total Vendido"
            }
        ));
        tfTabela.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tfTabelaMouseClicked(evt);
            }
        });
        tfTabela.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tfTabelaKeyReleased(evt);
            }
        });
        jScrollPane6.setViewportView(tfTabela);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addGap(91, 91, 91)
                .addComponent(jLabel1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 350, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel16)
                                    .addGap(52, 52, 52)
                                    .addComponent(tfValorCompra1, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel7)
                                    .addGap(67, 67, 67)
                                    .addComponent(tfQuantidadeMinima1))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel6)
                                    .addGap(50, 50, 50)
                                    .addComponent(tfQuantidadeDisponivel1)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel3))
                                .addGap(113, 113, 113)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(tfNome1, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
                                    .addComponent(tfPreco1))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addGap(0, 0, Short.MAX_VALUE))
            .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 470, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(10, 10, 10)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tfNome1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(tfPreco1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(tfQuantidadeDisponivel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton2)
                        .addGap(14, 14, 14)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(tfQuantidadeMinima1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(tfValorCompra1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 12, Short.MAX_VALUE))
        );

        jButton4.setText("Cancelar");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(410, 410, 410)
                .addComponent(jButton4)
                .addGap(0, 17, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton4)
                .addContainerGap(17, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        apagar();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        adicionarProdutoNaLista();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        dispose();
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        editar();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void tfTabelaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfTabelaKeyReleased

        selecionaItemNaTabela();

    }//GEN-LAST:event_tfTabelaKeyReleased

    private void tfTabelaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tfTabelaMouseClicked
        selecionaItemNaTabela();
    }//GEN-LAST:event_tfTabelaMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CadastrodeProduto.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CadastrodeProduto.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CadastrodeProduto.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CadastrodeProduto.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the dialog
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                CadastrodeProduto dialog = new CadastrodeProduto(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTable2;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextArea tfDescricao1;
    private javax.swing.JTextField tfNome1;
    private javax.swing.JTextField tfPreco1;
    private javax.swing.JTextField tfQuantidadeDisponivel1;
    private javax.swing.JTextField tfQuantidadeMinima1;
    private javax.swing.JTable tfTabela;
    private javax.swing.JTextField tfValorCompra1;
    // End of variables declaration//GEN-END:variables
}
